Skip to content

FAC-34 feat: implement login strategy pattern for auth service#60

Merged
y4nder merged 1 commit intodevelopfrom
feat/fac-34
Mar 1, 2026
Merged

FAC-34 feat: implement login strategy pattern for auth service#60
y4nder merged 1 commit intodevelopfrom
feat/fac-34

Conversation

@y4nder
Copy link
Member

@y4nder y4nder commented Feb 25, 2026

Summary

  • Refactored AuthService.Login() to use a strategy pattern separating local password auth from Moodle SSO
  • Added LoginStrategy interface with priority-based ordering for extensibility
  • Created LocalLoginStrategy (priority 10) and MoodleLoginStrategy (priority 100)
  • Added eslint rule to allow underscore-prefixed unused params project-wide

Changes

  • New files: src/modules/auth/strategies/ - interface, implementations, and tests
  • Modified: AuthService now injects and sorts strategies by priority
  • Modified: eslint.config.mjs - added argsIgnorePattern: '^_' rule

Test plan

  • All 103 unit tests pass
  • Lint passes
  • Priority sorting verified with dedicated test
  • MoodleConnectivityError handling preserved
  • Manual test: local user login
  • Manual test: Moodle SSO login

Refactor AuthService.Login() to use a strategy pattern that separates
local password authentication from Moodle SSO authentication.

- Add LoginStrategy interface with priority-based ordering
- Create LocalLoginStrategy (priority 10) for local password auth
- Create MoodleLoginStrategy (priority 100) for Moodle SSO
- Strategies auto-sorted by priority in AuthService constructor
- Add eslint rule to allow underscore-prefixed unused params
- Preserve transactional integrity and MoodleConnectivityError handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@y4nder y4nder self-assigned this Feb 25, 2026
@y4nder y4nder merged commit d09217a into develop Mar 1, 2026
2 checks passed
y4nder added a commit that referenced this pull request Mar 9, 2026
Refactor AuthService.Login() to use a strategy pattern that separates
local password authentication from Moodle SSO authentication.

- Add LoginStrategy interface with priority-based ordering
- Create LocalLoginStrategy (priority 10) for local password auth
- Create MoodleLoginStrategy (priority 100) for Moodle SSO
- Strategies auto-sorted by priority in AuthService constructor
- Add eslint rule to allow underscore-prefixed unused params
- Preserve transactional integrity and MoodleConnectivityError handling
y4nder added a commit that referenced this pull request Mar 9, 2026
…38, FAC-39] (#76)

* FAC-30 chore removed semantic release feature (#55)

* FAC-32 yaml file for contract schema (#58)

* FAC-33 feat: add Moodle connectivity error handling with timeouts (#59)

When Moodle is unreachable or times out, the API now returns a clear
401 Unauthorized with "Moodle service is currently unreachable" instead
of a generic 500 error. This improves frontend error handling and
server-side debugging with detailed logging.
- Add MoodleConnectivityError custom error class with 10s request
timeout  - Catch connectivity errors in AuthService.Login and map to 401
response  - Enhance logging in MoodleSyncService and
MoodleUserHydrationService  - Add 5 unit tests for connectivity error
scenarios

* FAC-34 feat: implement login strategy pattern for auth service (#60)

Refactor AuthService.Login() to use a strategy pattern that separates
local password authentication from Moodle SSO authentication.

- Add LoginStrategy interface with priority-based ordering
- Create LocalLoginStrategy (priority 10) for local password auth
- Create MoodleLoginStrategy (priority 100) for Moodle SSO
- Strategies auto-sorted by priority in AuthService constructor
- Add eslint rule to allow underscore-prefixed unused params
- Preserve transactional integrity and MoodleConnectivityError handling

* FAC-35 feat: added Refresh token cleanup (#61)

* FAC-35 feat: added Refresh token cleanup

* fix: linting issues

* fix: fixing linting issue

* FAC-36 chore: updated documentation (#62)

* FAC-36 chore: updated documentation

* chore: updated data model documentation

* FAC-37 feat: normalize role persisting and retrieval (#65)

* chore: Update Documentation

* FAC-38 feat: added faculty instructor context on enrollment response (#73)

* FAC-39 chore: security issues from dependabot (#75)
y4nder added a commit that referenced this pull request Mar 9, 2026
…38, FAC-39] (#76)

* FAC-30 chore removed semantic release feature (#55)

* FAC-32 yaml file for contract schema (#58)

* FAC-33 feat: add Moodle connectivity error handling with timeouts (#59)

When Moodle is unreachable or times out, the API now returns a clear
401 Unauthorized with "Moodle service is currently unreachable" instead
of a generic 500 error. This improves frontend error handling and
server-side debugging with detailed logging.
- Add MoodleConnectivityError custom error class with 10s request
timeout  - Catch connectivity errors in AuthService.Login and map to 401
response  - Enhance logging in MoodleSyncService and
MoodleUserHydrationService  - Add 5 unit tests for connectivity error
scenarios

* FAC-34 feat: implement login strategy pattern for auth service (#60)

Refactor AuthService.Login() to use a strategy pattern that separates
local password authentication from Moodle SSO authentication.

- Add LoginStrategy interface with priority-based ordering
- Create LocalLoginStrategy (priority 10) for local password auth
- Create MoodleLoginStrategy (priority 100) for Moodle SSO
- Strategies auto-sorted by priority in AuthService constructor
- Add eslint rule to allow underscore-prefixed unused params
- Preserve transactional integrity and MoodleConnectivityError handling

* FAC-35 feat: added Refresh token cleanup (#61)

* FAC-35 feat: added Refresh token cleanup

* fix: linting issues

* fix: fixing linting issue

* FAC-36 chore: updated documentation (#62)

* FAC-36 chore: updated documentation

* chore: updated data model documentation

* FAC-37 feat: normalize role persisting and retrieval (#65)

* chore: Update Documentation

* FAC-38 feat: added faculty instructor context on enrollment response (#73)

* FAC-39 chore: security issues from dependabot (#75)
@y4nder y4nder mentioned this pull request Mar 9, 2026
y4nder added a commit that referenced this pull request Mar 9, 2026
* FAC-30 chore removed semantic release feature (#55)

* FAC-32 yaml file for contract schema (#58)

* FAC-33 feat: add Moodle connectivity error handling with timeouts (#59)

When Moodle is unreachable or times out, the API now returns a clear
401 Unauthorized with "Moodle service is currently unreachable" instead
of a generic 500 error. This improves frontend error handling and
server-side debugging with detailed logging.
- Add MoodleConnectivityError custom error class with 10s request
timeout  - Catch connectivity errors in AuthService.Login and map to 401
response  - Enhance logging in MoodleSyncService and
MoodleUserHydrationService  - Add 5 unit tests for connectivity error
scenarios

* FAC-34 feat: implement login strategy pattern for auth service (#60)

Refactor AuthService.Login() to use a strategy pattern that separates
local password authentication from Moodle SSO authentication.

- Add LoginStrategy interface with priority-based ordering
- Create LocalLoginStrategy (priority 10) for local password auth
- Create MoodleLoginStrategy (priority 100) for Moodle SSO
- Strategies auto-sorted by priority in AuthService constructor
- Add eslint rule to allow underscore-prefixed unused params
- Preserve transactional integrity and MoodleConnectivityError handling

* FAC-35 feat: added Refresh token cleanup (#61)

* FAC-35 feat: added Refresh token cleanup

* fix: linting issues

* fix: fixing linting issue

* FAC-36 chore: updated documentation (#62)

* FAC-36 chore: updated documentation

* chore: updated data model documentation

* FAC-37 feat: normalize role persisting and retrieval (#65)

* chore: Update Documentation

* FAC-38 feat: added faculty instructor context on enrollment response (#73)

* FAC-39 chore: security issues from dependabot (#75)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant